Skip to content

refactor(extract): move extract_terraform to extractors/terraform.py (verbatim)#1721

Closed
Cekaru wants to merge 1 commit into
Graphify-Labs:v8from
Cekaru:refactor/extract-terraform
Closed

refactor(extract): move extract_terraform to extractors/terraform.py (verbatim)#1721
Cekaru wants to merge 1 commit into
Graphify-Labs:v8from
Cekaru:refactor/extract-terraform

Conversation

@Cekaru

@Cekaru Cekaru commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Part of the extract.py split tracked in #1212. Ports the Terraform/HCL extractor into its own per-language module.

What changed

  • Moved extract_terraform and its private _TF_META_HEADS constant verbatim into graphify/extractors/terraform.py.
  • extract.py keeps the facade re-export (from graphify.extractors.terraform import extract_terraform # noqa: F401), so every existing importer (__main__.py, watch.py, tests, etc.) is unchanged.
  • Registered in extractors/__init__.LANGUAGE_EXTRACTORS (alphabetical).
  • Added tests/test_extractors_registry.py with module-import / facade-identity / registry-identity checks.
  • Updated extractors/MIGRATION.md status table.

Behavior preservation

  • git diff --color-moved confirms the function + constant are byte-identical (verified locally with diff).
  • Net effect on extract.py: -178 lines, +1 import line — a pure move.
  • Helper classification: _TF_META_HEADS had 0 remaining uses after the move → private → moved with the function (per MIGRATION.md).

Tests

  • test_terraform.py (8) + test_extractors_registry.py (1) pass.
  • test_extract.py (114) pass.
  • No test edits outside the new registry test.

…(verbatim)

Ports the Terraform/HCL extractor out of the 17k-line extract.py into its
own per-language module, continuing the split tracked in Graphify-Labs#1212.

- extract_terraform and its private _TF_META_HEADS constant moved verbatim
  (git diff --color-moved confirms byte-identity; the existing test_terraform.py
  suite passing is the behavior-preservation proof).
- extract.py keeps the facade re-export so all existing importers are unchanged.
- Registered in extractors/__init__.LANGUAGE_EXTRACTORS (alphabetical).
- Added tests/test_extractors_registry.py with module/facade/registry identity
  checks; MIGRATION.md status table updated.
@Cekaru Cekaru force-pushed the refactor/extract-terraform branch from e897e91 to 404b222 Compare July 7, 2026 21:32
safishamsi pushed a commit that referenced this pull request Jul 9, 2026
…ge split (#1721)

The extract_terraform move #1721 proposed already landed on v8 via the #1737
decomposition (extractors/terraform.py exists, extract.py re-exports it, and
extractors/LANGUAGE_EXTRACTORS registers it), so the code move is a no-op now.
But the regression test @Cekaru added with it had no equivalent on v8. Salvage
and generalize it: sweep every LANGUAGE_EXTRACTORS entry and assert graphify.
extract re-exports the SAME object (facade identity) and the registry maps to
it (registry identity), plus the concrete terraform anchor from the PR. This
institutionalizes the re-export-identity guarantee the split relies on, so a
future move that forgets a facade re-export fails loudly.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@safishamsi

Copy link
Copy Markdown
Collaborator

Thanks @Cekaru. The Terraform move itself already landed on v8 as part of the larger #1737 decomposition — graphify/extractors/terraform.py exists with extract_terraform (+ _TF_META_HEADS) moved verbatim, extract.py keeps the facade re-export, and extractors/LANGUAGE_EXTRACTORS registers it. That's why this PR now shows as conflicting: the code change is a no-op against current v8.

The part that wasn't already covered is the regression test you added — there was no facade/registry-identity guard on v8. I salvaged it in 9c27a52 (authored to you) and generalized it: instead of one assertion per language, it sweeps the whole LANGUAGE_EXTRACTORS registry and asserts graphify.extract re-exports the same object and the registry maps to it, plus your concrete terraform anchor. So a future move that forgets a facade re-export now fails loudly.

Closing since the move is already in and the test is merged. Appreciate the clean, verified-move approach — exactly the right pattern for the split.

@safishamsi safishamsi closed this Jul 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants